home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / MAC OS 8 / cmm-framework-10.sit / Trygve's CMM Framework 1.0 / Sample Plugin (text beeper) / Plugin.cp next >
Text File  |  1997-08-28  |  2KB  |  73 lines

  1. //
  2. // Copyright ゥ1997 by Trygve Isaacson. All Rights Reserved.
  3. //
  4. // Additional Restrictions:
  5. //
  6. // Permission granted to:
  7. // - Compile this source code.
  8. // - Modify this source code, but not to remove this copyright information.
  9. // - Freely distribute the compiled object form of this source code, and any
  10. //   modifications you make, in your programs.
  11. //
  12. // Permission NOT granted to:
  13. // - Redistribute modified versions of this source code.
  14. //
  15. // You grant Trygve Isaacson one single-user license to your plugins based
  16. // on this source code, and notify him at:
  17. // trygve@bombaydigital.com
  18. //
  19.  
  20. #include "Plugin.h"
  21.  
  22. #undef Inherited
  23. #define Inherited PluginBase
  24.  
  25. #define    kBeepCommand    0
  26.  
  27. Plugin::Plugin()
  28.     {
  29.     }
  30.  
  31. Plugin::~Plugin()
  32.     {
  33.     }
  34.  
  35. /*
  36. Since we are just processing FSSpec items, we can use this method to filter out
  37. unwanted files based on the file type. We only want 'TEXT' files, but we don't
  38. care about the creator.
  39. */
  40.  
  41. Boolean Plugin::IsDesiredFSSpec(const FSSpec* aFileSpec, SInt32 /*commandID*/, Boolean /*isExaminePhase*/)
  42.     {
  43.     return this->IsSpecificCreatorType(aFileSpec, '****', 'TEXT');
  44.     }
  45.  
  46. /*
  47. This plugin just beeps once for each selected file. The default behavior of the
  48. plugin base class is to process typeFSS data, and we override above to filter
  49. out non-TEXT files.
  50. So if ANY of the data matched our criteria, we add a single Beep command to the menu.
  51. */
  52.  
  53. Boolean Plugin::AddMultiDataTypeCommand(AEDescList* commandList, UInt32 /*numDataTypes*/, OSType* /*dataTypesArray*/, UInt32 numDataTypesFound)
  54.     {
  55.     if (numDataTypesFound > 0)
  56.         this->AddCommand(commandList, "¥pBeep", kBeepCommand);
  57.  
  58.     return true;    // true means do NOT call AddDataTypeCommand for individual data types
  59.     }
  60.  
  61. /*
  62. This is the first place in the calling sequence where we can process a selected item.
  63. This will be called for each text file in the selection. We beep.
  64. */
  65.  
  66. OSStatus Plugin::ProcessSelectionItem(AEDesc* /*coercedDescriptor*/, SInt32 /*commandID*/)
  67.     {
  68.     ::SysBeep(5);
  69.  
  70.     return noErr;
  71.     }
  72.  
  73.